package com.example.springblog.mapper;

import com.example.springblog.model.BlogInfo;
import com.example.springblog.model.BlogList;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface BlogMapper {
    /*
    * 查询博客列表
    * */
    @Select("select * from blog where delete_flag=0 order by create_time desc")
    public List<BlogList> selectAll();
    @Select("select * from blog where delete_flag=0 and id=#{id}")
    public BlogInfo selectById(Integer id);
    /**
     * 更新博客
     */
    Integer updateBlog(BlogInfo blogInfo);
    /**
     * 发布博客
     */
    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);
}
